home *** CD-ROM | disk | FTP | other *** search
/ Hackers Handbook - Millenium Edition / Hackers Handbook.iso / library / hack / swish-E.txt < prev    next >
Encoding:
Internet Message Format  |  1998-11-21  |  3.9 KB

  1. Date: Mon, 9 Nov 1998 22:00:33 +0100
  2. From: Job de Haas <job@ITSX.COM>
  3. To: BUGTRAQ@netspace.org
  4. Subject: Vulnerabilities with Swish
  5.  
  6.  
  7. -----BEGIN PGP SIGNED MESSAGE-----
  8. Hash: SHA1
  9.  
  10. Hello,
  11.  
  12. While installing the Swish search engine (http://sunsite.berkeley.edu/SWISH-E)
  13. at our site (http://www.itsx.com) we discovered several (potential)
  14. vulnerabilities. Swish-e and the accompanying configuration package AutoSwish
  15. contain vulnerabilities in the source code of the indexer, in an example perl
  16. script and in the perl scripts generated by AutoSwish for setting up an entry
  17. form. Although the major problem is in the example script we found that
  18. several sites use this. Also the well known nature of these issues doesn't
  19. seem to make it less desirable to point them out (again).
  20.  
  21. Impact
  22. ------
  23.  
  24. The vulnerabilities could allow remote access to the web-server as the user
  25. that the server is running as.
  26.  
  27. Description
  28. -----------
  29.  
  30. 1) Perl script problems
  31.  
  32. Perl scripts to interface to the indexing and search program are provided
  33. in two fashions: as plain example scripts and auto generated by the
  34. AutoSwish configuration tool.  The example scripts are provided on the web
  35. site for Swish ( http://sunsite.berkeley.edu/SWISH-E/Manual/webscripts.html).
  36. The scripts call the search program with parameters in the following manner:
  37.  
  38.         open(SWISH,"$swish -w $query -m $results -f $index|");
  39.  
  40. The example scripts do this without stripping the user supplied arguments of
  41. shell meta-characters, AutoSwish generated scripts do some stripping.
  42. Still, subversion might be possible by providing command line arguments as
  43. search strings. This is a problem due to the way the arguments are processed
  44. by the indexing program.
  45.  
  46. This behavior can be prevented by using exec (which enforces the query to
  47. be a single argument) and by removing any leading dashes from the user
  48. supplied strings.
  49.  
  50. This should possibly be something like:
  51.  
  52.         $query =~ s/^-+(.*)/$1/;
  53.         $results =~ s/^-+(.*)/$1/;
  54.         open(SWISH,"-|") || exec $swish,"-w",$query,"-m",$results,"-f",$index;
  55.  
  56.  
  57. 2) Buffer overflows
  58.  
  59. The code of the actual index and search program contains numerous buffer
  60. overflows. These are too superfluous to mention. For the arguments these can
  61. be circumvented by doing some preliminary limitation on the size of these
  62. user supplied arguments. The following will allow you to keep using the
  63. binaries you have:
  64.  
  65.         $query =~ s/(.{256}).*/$1/;
  66.         $results =~ s/(.{256}).*/$1/;
  67.  
  68. Of course limiting the allowable characters in the query also severely limits
  69. the possibilities for exploiting an overflow. We have not fully evaluated what
  70. the impact could be when a user has control over the files being indexed.
  71.  
  72. Solution
  73. --------
  74.  
  75. Make sure that the program executing the index program 'swish' does not
  76. perform argument expansion and meta-character interpretation in a shell,
  77. disallows user supplied arguments starting with a dash and limits the
  78. arguments to safe lengths (no larger than 1000 bytes). A proposed patch is
  79. attached below.
  80.  
  81. Relevant information concerning security issues while programming for web
  82. sites can be found at http://www.w3.org/Security/Faq/www-security-faq.html
  83.  
  84.  
  85. Job
  86.  
  87. --------------------------
  88. Job de Haas | job@itsx.com
  89. ITSX | http://www.itsx.com
  90.  
  91.  
  92. Patch for samplescript:
  93. ===========================
  94.  
  95. --- samplescript        Tue Sep 29 14:01:35 1998
  96. +++ samplescript.new    Mon Nov  2 22:27:46 1998
  97. @@ -72,7 +72,11 @@
  98.  
  99.  $count=0;
  100.  
  101. -open(SWISH, "$swish -w $query -m $results -f $index|");
  102. +# Remove leading dashes and limit to 256 characters
  103. +$query =~ s/^-+(.*)/$1/;
  104. +$results =~ s/^-+(.*)/$1/;
  105. +$query =~ s/(.{256}).*/$1/;
  106. +$results =~ s/(.{256}).*/$1/;
  107. +open(SWISH,"-|") || exec $swish,"-w",$query,"-m",$results,"-f",$index;
  108.  
  109.  #Check for errors
  110.  
  111. ============================
  112.  
  113.  
  114.  
  115. -----BEGIN PGP SIGNATURE-----
  116. Version: PGP 5.0i
  117.  
  118. iQA/AwUBNkdVaEkv/Q0TLteWEQKbhwCglavJWSnPZA3EXavd7uwNAKEmVW4AoOve
  119. wyH89An7Xpslf46KooGvGxyQ
  120. =dPji
  121. -----END PGP SIGNATURE-----
  122.